{extend name="admin@public/base_content" /}
{block name="body">}
<body>
{include file="admin@public/common" /}
<div class="container-fluid larry-wrapper">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12">
            <section class="panel panel-padding">
                <form id="form1" class="layui-form layui-form-pane" action="{:url('')}">
                    <div class="layui-tab" lay-filter="check">
                        <ul class="layui-tab-title">
                            <li class="layui-this" lay-id="1">基本信息</li>
                            <li lay-id="2">扩展信息</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">文章分类</label>
                                    <div class="layui-input-inline">
                                        <select jq-verify="required" jq-error="请选择文章分类" lay-filter="class_id" name="class_id">
                                            <option value="">请选择</option>
                                            {foreach name="category_list" item="vo"}
                                            <option value="{$vo.class_id}" {if condition="$vo.class_id eq $info.class_id"}selected{/if} {if condition="($vo.type eq 0) or ($vo.app neq request()->module())"} disabled="disabled" {/if}>{$vo.cname}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">文章标题</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="title" value="{$info.title|default=''}" jq-verify="required" jq-error="请输入文章标题" placeholder="请输入文章标题" class="layui-input ">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">形象图</label>
                                    <div class="layui-input-block">
                                        <input type="file" name="image" class="layui-upload-file">
                                        <input type="hidden" name="image" value="{$info.image|default=''}" jq-error="请上传形象图" error-id="img-error">
                                        <p id="img-error" class="error"></p>
                                    </div>
                                    {notempty name="info.image"}
                                    <div class="layui-input-block">
                                        <div class="imgbox"><img src="{$info.image|default=''}" alt="..." class="img-thumbnail"></div>
                                    </div>
                                    {/notempty}
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">内容</label>
                                    <div class="layui-input-block">
                                        <textarea name="content" class="king_content" cols="100" rows="20">{$info.content|default=''}</textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item ">
                                    <label class="layui-form-label">文章描述</label>
                                    <div class="layui-input-block">
                                        <textarea name="description" placeholder="请输入文章描述" class="layui-textarea">{$info.description|default=''}</textarea>
                                    </div>
                                </div>

                                <div id="expand"></div>

                                <div class="layui-form-item" pane>
                                    <label class="layui-form-label">文章状态</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="status" {eq name="info.status" value="1"}checked{/eq} title="显示" value="1" checked />
                                        <input type="radio" name="status" {eq name="info.status" value="2"}checked{/eq} title="关闭" value="2" />
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">排序</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="sequence"  jq-verify="number" value="{$info.sequence|default='0'}" jq-error="排序必须为数字" placeholder="分类排序" class="layui-input ">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">推荐位置</label>
                                    <div class="layui-input-block">
                                        {php} $positionArray = explode(',',$info['position']);{/php}
                                        {foreach name='position_list' item='vo'}
                                        <input type="checkbox" value="{$vo.position_id}" {if condition='in_array($vo.position_id,$positionArray)'}checked{/if} name="position[{$key}]" title="{$vo.name}">
                                        {/foreach}
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">内容url</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="urltitle" value="{$info.urltitle|default=''}" jq-error="设置URL规则后会生效" placeholder="设置URL规则后会生效" class="layui-input ">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">跳转到</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="url" value="{$info.url|default=''}" jq-error="设置后访问内容会跳转" placeholder="设置后访问内容会跳转" class="layui-input ">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">发布时间</label>
                                    <div class="layui-input-block">
                                        <input name="date" value="{$Think.NOW_TIME}" id="date" lay-verify="date" placeholder="发布时间" class="layui-input" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm'})" type="text">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">访问量</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="views"  jq-verify="number" value="{$info.views|default='0'}" jq-error="排序必须为数字" placeholder="分类排序" class="layui-input ">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">页面模板</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="tpl" id="tpl" value="{$info.tpl|default=''}"  class="layui-input ">
                                    </div>
                                    <div class="layui-input-inline">
                                        <select jq-error="请选择" lay-filter="tpl">
                                            <option value=""></option>
                                            {foreach name='tplList' item='vo'}
                                            <option value="{$vo.name}" {if condition="$vo.name eq $info.tpl"}selected{/if}>{$vo.file}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="content_id" value="{$info.content_id|default=''}">
                            <button class="layui-btn" jq-submit lay-filter="submit" jq-tab="true">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </section>
        </div>
    </div>
</div>
</body>
{/block}
{block name="script"}
<!--kingeditor编辑器开始-->
<script>
    //document.domain = 'domain.com';
    KindEditor.ready(function(K) {
        window.editor = K.create('.king_content', {
            allowFileManager : true,
            langType : 'zh-CN',
            autoHeightMode : true,
            afterBlur: function () { this.sync(); },
        });
    });
</script>
<!--kingeditor编辑器结束-->
<script>
    layui.use('myform', function(){
        var form = layui.form();
        var $= layui.jquery;
        //各种基于事件的操作，下面会有进一步介绍
        form.on('select(tpl)', function(data){
            document.getElementById("tpl").value=data.value;
        });
        window.onload=function(){
            url="{:url('/kbcms/admin_expand/getField')}";
            $.post(url,{
                class_id:'{$info.class_id}',
                content_id:'{$info.content_id}'
            },function(data){
                $('#expand').html(data);
            });
        }
        form.on('select(class_id)', function(data){
            url="{:url('/kbcms/admin_expand/getField')}";
            $.post(url,{
                class_id:data.value,
                content_id:'{$info.content_id}'
            },function(data){
                $('#expand').html(data);
            });
            //alert(data.value);
        });
    });
</script>
{/block}